#include "kuozhangmanager.h"
#include "utils/imghelper.h"
#include "setting.h"
using namespace cv;
Q_GLOBAL_STATIC(KuoZhangManager, instance)
KuoZhangManager::KuoZhangManager()
{

}

KuoZhangManager *KuoZhangManager::getInstance()
{
    return instance();
}

int KuoZhangManager::getJiuYuanTask(QRectF &rectf, JiuYuanBean &jiuYuanBean)
{
    float imgDiscern = Setting::getInstance()->getImgDiscern();
    QRectF qRectFLocation = QRectF(0.1f,0.3f,0.6f,0.8f);
    if(ImgHelper::getGameMatchPoint(":/kuozhang/icon/kuozhang/shaolin_xuanci.png",Scalar(12,63,255), Scalar(180,255,255), imgDiscern, qRectFLocation, &rectf)){
       jiuYuanBean.remoteCityName = "shaolin";
       jiuYuanBean.fuBenNameEn = "tongrenxiang";
       jiuYuanBean.jiuRenLocationX = 15;
       jiuYuanBean.jiuRenLocationY = 16;
       jiuYuanBean.outLocationX = 31;
       jiuYuanBean.outLocationY = 53;
       jiuYuanBean.chuanSongX = 91;
       jiuYuanBean.chuanSongY = 130;
       jiuYuanBean.yizhanImg = ":/kuozhang/icon/kuozhang/npc_chuansong.png";
       QList<QPoint *> *killNpcNode = jiuYuanBean.killNpcNode;
       qDeleteAll(killNpcNode->begin(), killNpcNode->end());

       jiuYuanBean.killNpcNode->append(new QPoint(22,40));
       jiuYuanBean.killNpcNode->append(new QPoint(49,32));

        return TYPE_JIU_YUAN;
    }
    if(ImgHelper::getGameMatchPoint(":/kuozhang/icon/kuozhang/tianshan_meijian.png",Scalar(12,63,255), Scalar(180,255,255), imgDiscern, qRectFLocation, &rectf)){
       jiuYuanBean.remoteCityName = "tianshan";
       jiuYuanBean.fuBenNameEn = "zhemeifeng";
       jiuYuanBean.jiuRenLocationX = 11;
       jiuYuanBean.jiuRenLocationY = 11;
       jiuYuanBean.outLocationX = 25;
       jiuYuanBean.outLocationY = 50;
       jiuYuanBean.chuanSongX = 88;
       jiuYuanBean.chuanSongY = 120;
       jiuYuanBean.yizhanImg = ":/kuozhang/icon/kuozhang/npc_chuansong.png";
       QList<QPoint *> *killNpcNode = jiuYuanBean.killNpcNode;
       qDeleteAll(killNpcNode->begin(), killNpcNode->end());

       jiuYuanBean.killNpcNode->append(new QPoint(33,51));
       return TYPE_JIU_YUAN;
    }
    if(ImgHelper::getGameMatchPoint(":/kuozhang/icon/kuozhang/xingxiuhai_dingchunqiu.png",Scalar(12,63,255), Scalar(180,255,255), imgDiscern, qRectFLocation, &rectf)){
        jiuYuanBean.remoteCityName = "xingxiuhai";
        jiuYuanBean.fuBenNameEn = "wushendong";
        jiuYuanBean.jiuRenLocationX = 17;
        jiuYuanBean.jiuRenLocationY = 21;
        jiuYuanBean.outLocationX = 13;
        jiuYuanBean.outLocationY = 40;
        jiuYuanBean.chuanSongX = 98;
        jiuYuanBean.chuanSongY = 149;
        jiuYuanBean.yizhanImg = ":/kuozhang/icon/kuozhang/npc_chuansong.png";
        QList<QPoint *> *killNpcNode = jiuYuanBean.killNpcNode;
        qDeleteAll(killNpcNode->begin(), killNpcNode->end());

        jiuYuanBean.killNpcNode->append(new QPoint(18,43));
        return TYPE_JIU_YUAN;
    }
    if(ImgHelper::getGameMatchPoint(":/kuozhang/icon/kuozhang/wudang_zhangxuansu.png",Scalar(12,63,255), Scalar(180,255,255), imgDiscern, qRectFLocation, &rectf)){
        jiuYuanBean.remoteCityName = "wudang";
        return TYPE_JIU_YUAN;
    }
    if(ImgHelper::getGameMatchPoint(":/kuozhang/icon/kuozhang/gaibang_chenguyan.png",Scalar(12,63,255), Scalar(180,255,255), imgDiscern, qRectFLocation, &rectf)){
       jiuYuanBean.remoteCityName = "gaibang";
       jiuYuanBean.fuBenNameEn = "jiujiao";
       jiuYuanBean.jiuRenLocationX = 14;
       jiuYuanBean.jiuRenLocationY = 43;
       jiuYuanBean.outLocationX = 45;
       jiuYuanBean.outLocationY = 47;
       jiuYuanBean.chuanSongX = 93;
       jiuYuanBean.chuanSongY = 120;
       jiuYuanBean.yizhanImg = ":/kuozhang/icon/kuozhang/npc_chuansong.png";
       jiuYuanBean.diZiImg = ":/kuozhang/icon/kuozhang/npc_gaibangdizi.png";
       QList<QPoint *> *killNpcNode = jiuYuanBean.killNpcNode;
       qDeleteAll(killNpcNode->begin(), killNpcNode->end());

       jiuYuanBean.killNpcNode->append(new QPoint(44,43));
        return TYPE_JIU_YUAN;
    }
    if(ImgHelper::getGameMatchPoint(":/kuozhang/icon/kuozhang/tianlongsi_benyin.png",Scalar(12,63,255), Scalar(180,255,255), imgDiscern,qRectFLocation, &rectf)){
        jiuYuanBean.remoteCityName = "tianlong";
        jiuYuanBean.fuBenNameEn = "tadi";
        jiuYuanBean.jiuRenLocationX = 29;
        jiuYuanBean.jiuRenLocationY = 21;
        jiuYuanBean.outLocationX = 49;
        jiuYuanBean.outLocationY = 49;
        jiuYuanBean.chuanSongX = 96;
        jiuYuanBean.chuanSongY = 120;
        jiuYuanBean.diZiImg = ":/kuozhang/icon/kuozhang/npc_tianlongdizi.png";
        jiuYuanBean.yizhanImg = ":/kuozhang/icon/kuozhang/npc_chuansong.png";
        QList<QPoint *> *killNpcNode = jiuYuanBean.killNpcNode;
        qDeleteAll(killNpcNode->begin(), killNpcNode->end());

        jiuYuanBean.killNpcNode->append(new QPoint(42,46));
        return TYPE_JIU_YUAN;
    }
    if(ImgHelper::getGameMatchPoint(":/kuozhang/icon/kuozhang/dali_huanglingbo.png",Scalar(12,63,255), Scalar(180,255,255), imgDiscern, qRectFLocation, &rectf)){
       jiuYuanBean.remoteCityName = "dali";
       return TYPE_SEND_MESSAGE;
    }

    if(ImgHelper::getGameMatchPoint(":/kuozhang/icon/kuozhang/jiejiaoxin_qinhongmian.png",Scalar(12,63,255), Scalar(180,255,255), imgDiscern, qRectFLocation, &rectf)){
       jiuYuanBean.remoteCityName = "shilin";
       return TYPE_SEND_MESSAGE;
    }

    if(ImgHelper::getGameMatchPoint(":/kuozhang/icon/kuozhang/suzhou_chaobuzhi.png",Scalar(12,63,255), Scalar(180,255,255), imgDiscern, qRectFLocation, &rectf)){
       jiuYuanBean.remoteCityName = "suzhou";
       jiuYuanBean.chuanSongX = 109;
       jiuYuanBean.chuanSongY = 160;
       jiuYuanBean.yizhanImg = ":/kuozhang/icon/kuozhang/yizhanlaoban.png";
       return TYPE_SEND_MESSAGE;
    }

    if(ImgHelper::getGameMatchPoint(":/kuozhang/icon/kuozhang/search_product.png", Scalar(0,0,255), Scalar(0,0,255), imgDiscern, qRectFLocation)){
        return TYPE_ARTWARE;
    }

    if(ImgHelper::getGameMatchPoint("",Scalar(12,63,255), Scalar(180,255,255), imgDiscern,qRectFLocation, &rectf)){
       return TYPE_JIU_YUAN;
    }
    return TYPE_ERROR;
}

QString KuoZhangManager::getCityImg(QString cityName)
{
    if(cityName == "洛阳" || cityName == "luoyang"){
        return ":/kuozhang/icon/kuozhang/chuansong_luoyang.png";
    }else if(cityName == "苏州" || cityName == "suzhou"){
        return ":/kuozhang/icon/kuozhang/chuansong_suzhou.png";
    }else if(cityName == "大理" || cityName == "dali"){
        return ":/kuozhang/icon/kuozhang/chuansong_dali.png";
    }
    return "";
}

KuoZhangManager::~KuoZhangManager()
{

}
